<#assign ctx=base.contextPath>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>站点列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<script type="text/javascript">
		var ctx = '${ctx}';
	</script>
	<link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${ctx}/static/css/news.css" media="all" />
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
		<div class="layui-inline">
			<a class="layui-btn audit_btn">全部审核</a>
		</div>
	</blockquote>
	<div class="layui-form news_list">
	  	<table class="layui-table">
		    <thead>
				<tr>
					<th><input type="checkbox" lay-skin="primary" lay-filter="allChoose"  id="allChoose"></th>
					<th>评论ID</th>
					<th>评论者ID</th>
					<th>文章id</th>
					<th>创建时间</th>
					<th>是否推荐</th>
					<th>是否审核</th>
					<th width="20%">评论内容</th>
					<th>操作</th>
				</tr> 
		    </thead>
		    <tbody id="commentId">
		    	<tr v-for="(comment,index) in logList">
					<td><input type="checkbox" lay-skin="primary"  value="comment.commentId"></td>
					<td>{{comment.commentId}}</td>
					<td>{{comment.commentUserId}}</td>
					<td>{{comment.contentId}}</td>
					<td>{{new Date(comment.createTime).toLocaleString()}}</td>
					<td><i class="layui-icon">{{comment.isRecommend ?'&#xe618;':'&#x1006;' }}</i></td>
					<td v-model="comment.commentId"><i class="layui-icon">{{comment.isChecked==2?'&#xe618;':'&#x1006;' }}</i></td>
					<td>{{comment.comment}}</td>
					<td>
						<a href="JavaScript:void(0);" v-if="comment.isChecked==2" class="layui-btn layui-btn-mini">
							<i class="layui-icon">&#xe618;</i>已审核
						</a>
						<a href="JavaScript:void(0);" v-else class="layui-btn layui-btn-mini layui-btn-danger" @click="chkeckComment(comment.commentId, $event)">
							<i class="layui-icon">&#x1006;</i>&nbsp;&nbsp;审 &nbsp;&nbsp;核&nbsp;&nbsp;
						</a>
					</td>
				</tr>
		    </tbody>
		</table>
	</div>
	<div id="page"></div>
	<script type="text/javascript" src="${ctx}/static/layui/layui.js"></script>
	<script src="https://cdn.bootcss.com/vue/2.5.3/vue.min.js"></script>
	<script src="https://cdn.bootcss.com/vue-resource/1.3.3/vue-resource.min.js"></script>
</body>
<script type="text/javascript">
var page;
var layer = layui.config({
	base : "js/"
}).use(['form','layer','jquery','laypage'],function(){
	var form = layui.form();
	$ = layui.jquery;
	form.on('checkbox(allChoose)', function(data){
		var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]:not([name="show"])');
		child.each(function(index, item){
			item.checked = data.elem.checked;
		});
		form.render('checkbox');
	});
})
var logApp = new Vue({
	  el: '#commentId',
	  data:{
		  logList:[]
	  },
	  created:function(){
          this.$http.get('/comment/getCommnetList.json').then(function(data){
              this.logList=data.body.data.list;
              var data= data;
              layui.use('laypage', function(){
	           	  var laypage = layui.laypage;
	           	  laypage({
	           			cont : "page",
	           			pages : data.body.data.pages,
	           			jump : function(obj,first){
	           				if(!first){
		           				logApp.$http.get('/comment/getCommnetList.json?pageNum='+obj.curr).then(function(data){
		           					logApp.logList=data.body.data.list;
			                   }) 
	           				}
	           			}
	           		})
          	 });
          })
       }
})
function chkeckComment(id, event){
	var p = id?"?id="+id:'';
	logApp.$http.get(ctx+"/comment/chckedAllOrId"+p).then(function(data){
		if(!(data.body.code)&&(data.body.code)==0){
			window.location.reload();
		}else{
			 layer.msg('请求失败，请刷新页面重试', {icon: 5,time: 1500}); 
		}
   }) 
	
}
</script>
</script>
</html>